package org.streamerstudio.ui.properties;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.streamerstudio.model.gstreamer.registry.GstPlugin;

public class PluginPropertySection extends AbstractPropertySection {

	private PluginPropertyComposite pluginPropertyComposite;
	
	public PluginPropertySection() {
	}


	@Override
	public void refresh() {
		if (pluginPropertyComposite != null){
			pluginPropertyComposite.update();
		}
	}

	@Override
	public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
		super.createControls(parent, aTabbedPropertySheetPage);
		pluginPropertyComposite = new PluginPropertyComposite(parent, SWT.NONE);
	}

	@Override
	public void setInput(IWorkbenchPart part, ISelection selection) {
		super.setInput(part, selection);
        if (selection instanceof IStructuredSelection){
	        Object input = ((IStructuredSelection) selection).getFirstElement();
	        if (GstPlugin.class.isAssignableFrom(input.getClass())){
	        	pluginPropertyComposite.setInput((GstPlugin)input);
	        }
        }
    }
}
